Within the C++ programming language, programmers have created a functional programming language using various implementations of the template and the type system. Current compiler implementations allow programmers to program complex problems using template instantiations, which enable aspects of the problems to be solved at compile time rather than at run time. However, the type system of the compiler is not designed to handle the large number of template instantiations and types created while computing the results. As use of the type system increases the performance of the compiler degrades.
For example, in the following code snippet, the template class Fib<20> will create Fib<19> and Fib<18>. This progressive instantiation continues until the specializations Fib<l> and Fib<O> are used. The specializations provide termination of the recursive process.
template <int N>
struct Fib {
enum E {Result=Fib<N-1>::Result+Fib<N-2>::Result};
};
template <> struct Fib<O> {enum{Result=0};1;
template <> struct Fib<l> {enum{Result=0};};
int x=Fib<20>::Result;
Although the user only used Fib<20>, other instantiations were required to compute the result. In this case the number of extra instantiations grows linearly with the value of the template argument. Use of Fib<21> will only require one more instantiation than Fib<20>.
As program complexity increases, so does the recursion thereby causing an overload of the regular type system. As the regular type system of the compiler becomes overloaded the compilation time increases due to the number of and size of entries to be processed as well as the time required for performing the compilations.